package com.hundsun.fcp.common.utils;

import android.app.Activity;
import android.widget.Toast;

import com.hundsun.fcp.widget.crouton.Configuration;
import com.hundsun.fcp.widget.crouton.Crouton;
import com.hundsun.fcp.widget.crouton.Style;

public class ToastUtil {
	
	public static final int SHORT = 0 ;
	
	public static final int LONG = 1 ;

	private static void showCroutonToast(Activity pActivity, String pMessage,
			Style pStyle, int duration) {
		if (pActivity != null) {
			if (duration == SHORT) {
				duration = 1000;
			} else {
				duration = 2000;
			}
			Configuration configuration = new Configuration.Builder()
					.setDuration(duration).build();
			Crouton.makeText(pActivity, pMessage, pStyle)
					.setConfiguration(configuration).show();

		}
	}

	public static void showConfirmToast(Activity pActivity, String pMessage,
			int duration) {
		showCroutonToast(pActivity, pMessage, Style.CONFIRM, duration);
	}

	public static void showConfirmToast(Activity pActivity, int resId,
			int duration) {
		showCroutonToast(pActivity, pActivity.getString(resId), Style.CONFIRM,
				duration);
	}
	
	 public static void showAlertToast(Activity pActivity, String pMessage, int duration)
	  {
	    showCroutonToast(pActivity, pMessage, new Style.Builder().setBackgroundColorValue(0x7FFF4444).build(), duration);
	  }
	
	 public static void showInfoToast(Activity pActivity, int resId, int duration)
	  {
	    showInfoToast(pActivity, pActivity.getString(resId), duration);
	  }

	 public static void showInfoToast(Activity pActivity, String pMessage, int duration)
	  {
	    showCroutonToast(pActivity, pMessage, new Style.Builder().setBackgroundColorValue(0x99000000).build(), duration);
	  }
	 
}
